#!/bin/bash - 

set -o errexit # Exit on error

git add .
git pull

read -p "输入项目名（不填打包全部项目）:" name
name=${name:-all}
echo "$name"

if [ $name = "all" ]; then
  echo "开始打包所有项目..."
  npm run build &npm run build -bank &npm run build -chick &npm run build -credit &npm run build -gov &npm run build -gxs
else
  echo "开始打包项目：$name..."
  npm run build -$name
fi

echo "打包完成，开始提交git..."

cd ../..
pwd

# git add .
# npx git-cz
# git push

get_char()
{
  SAVEDSTTY=`stty -g`
  stty -echo
  stty cbreak
  dd if=/dev/tty bs=1 count=1 2> /dev/null
  stty -raw
  stty echo
  stty $SAVEDSTTY
}
 
echo "提交成功，按任意键继续..."
char=`get_char`
echo "完成..."
